package com.hnx.admin.utils;

import com.hnx.admin.api.http.HttpStatusAPI;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.Writer;

/*
项目名称： core
创 建 人: 倔强的头发
创建日期： 2025/5/29   17:45:05 
描   述：
*/
public class ResponseUtil implements HttpStatusAPI {
    public static void write(HttpServletResponse response, String text) {
        write(response, text, JSON);
    }

    public static void write(HttpServletResponse response, String text, String contentType) {
        response.setContentType(contentType);
        Writer writer = null;

        try {
            writer = response.getWriter();
            writer.write(text);
            writer.flush();
        } catch (IOException var8) {
            throw new RuntimeException(var8);
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (Exception ex) {
                }
            }
        }
    }
}
